<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 郑帅
  Date: 2019/8/17
  Time: 14:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>

<script src="<c:url value="/layui/layui.js"/>"></script>
<link rel="stylesheet" type="text/css" href="<c:url value="/layui/css/layui.css"/>">
<body>

<%--<div id="demo20"></div>--%> <%--<ul id="biuuu_city_list"></ul>--%>
<div class="demoTable">
    客户编号：
    <div class="layui-inline">
        <input class="layui-input" name="id" id="CustomerId" autocomplete="off">
    </div>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 客户名称：
    <div class="layui-inline">
        <input class="layui-input" name="id" id="CustomerName" autocomplete="off">
    </div>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 所在地区：
    <div class="layui-inline">
        <select name="interest" lay-verify="required" style="width:100px;height: 35px" id="CustomerArea">
            <option value="" selected="">全部</option>
            <option value="北京">北2京</option>
            <option value="华北">华北</option>
            <option value="中南">中南</option>
            <option value="东北">东北</option>
            <option value="西部">西部</option>
        </select>
    </div>
    客户经理：
    <div class="layui-inline">
        <select name="interest" lay-verify="required" style="width:100px;height: 35px" id="CustomerManager">
            <option value="" selected="">全部</option>
            <c:forEach items="${Rolr}" var="k">
                <option value="${k.id}">${k.real_name}</option>
            </c:forEach> </select>
        </select>
    </div>
    <%--<input class="layui-input" name="id" id="CustomerManager" autocomplete="off">--%>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp 客户等级：
    <div class="layui-inline">
        <select name="interest" lay-verify="required" style="width:100px;height: 35px" id="CustomerType">
            <option value="" selected="">全部</option>
            <c:forEach items="${type}" var="k">
                <C:if test="${not empty k.type}">
                    <option value="${k.type}">${k.type}</option>
                </C:if>
            </c:forEach>
        </select>
    </div>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp

    <button class="layui-btn" data-type="reload" id="ss">搜索</button>
</div>
<table class="layui-hide" id="test" lay-filter="test" height=100></table>

<script src="<c:url value="/layui/layui.js"/>" charset="utf-8"></script>
<script src="<c:url value="/js/jquery-1.9.1.min.js"/>"></script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit" target="_self">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="Lankman">联系人</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="Jyjl">交易记录</a>
</script>
<script>
    $(function () {
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#test',
                url: '<c:url value="/load.do"/>',
                cellMinWidth: 95,
                page: true,
                height: "full-125",
                limits: [5, 10, 15, 20],
                limit: 5,
                id: "userListTable",

                height: "420px",
                response: {
                    statusName: 'code',// 对应 code
                    msgName: 'mag', // 对应 msg
                    countName: 'count', // 对应 count
                    dataName: 'data'  // 对应 data
                },

                cols: [[
                    // {field: 'stuid', title: 'ID', minWidth:100, align:"center"},
                    // {field: 'stuname', title: '姓名', align:'center'},
                    // {field: 'stuage', title: '年龄', align:'center',minWidth:150},
                    // {fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
                    {field: 'id', title: 'ID', minWidth: 100, align: "center"},
                    {field: 'name', title: '名称', align: 'center'},
                    {field: 'area', title: '地区', align: 'center', minWidth: 150},
                    {field: 'real_name', title: '客户经理', minWidth: 100, align: "center",width:238},
                    {field: 'Diname', title: '客户等级', align: 'center',width:200},
                    {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 250}

                ]]

            });
            table.on('tool(test)', function (obj) {
                var data = obj.data;
                console.log(data.id);
                if (obj.event === 'del') {
                    layer.confirm('真的删除行么', function (index) {
                        obj.del();
                        deleteCon(data.id);
                        layer.close(index);
                    });
                } else if (obj.event === 'edit') {
                    customerLoss(obj.data.id);
                }
                else if (obj.event === 'Lankman') {
                    Link(data.id,data.name);
                }
                else if (obj.event === 'Jyjl') {
                    Jyjl(data.id);
                }
            });
        });

        function deleteCon(id) {
            $.get('<c:url value="/delete.do"/>', {"id": id}, function (da) {
                alert("刪除成功");
            })
        }

        function customerLoss(id) {

            location.href = '<c:url value="/ConLoad.do?id="/>' + id;

        }
        function Link(id,name) {

            location.href = '<c:url value="/view/customer/Linkman.jsp?CutId="/>' + id+"&name="+name;

        }
        function Jyjl(id)
        {
            location.href = '<c:url value="/view/customer/Jyjl.jsp?CutId="/>' + id;
        }

        $("#ss").click(function () {
            var CustomerId = $("#CustomerId").val();
            var CustomerName = $("#CustomerName").val();
            var CustomerManager = $("#CustomerManager").val();
            var CustomerArea = $("#CustomerArea").val();
            var CustomerType = $("#CustomerType").val();
            layui.use('table', function () {
                var table = layui.table;
                table.render({
                    elem: '#test',
                    where: {
                        "CustomerId": CustomerId,
                        "CustomerName": CustomerName,
                        "CustomerManager": CustomerManager,
                        "CustomerArea": CustomerArea,
                        "CustomerType": CustomerType
                    },
                    url: '<c:url value="/query.do"/>',
                    cellMinWidth: 95,
                    page: true,
                    height: "full-125",
                    limits: [5, 10, 15, 20],
                    limit: 5,

                    id: "ListTable",
                    height: "420px",
                    response: {
                        statusName: 'code', // 对应 code
                        msgName: 'mag',     // 对应 msg
                        countName: 'count', // 对应 count
                        dataName: 'data'    // 对应 data
                    }
                    ,
                    cols: [[
                        // {field: 'stuid', title: 'ID', minWidth:100, align:"center"},
                        // {field: 'stuname', title: '姓名', align:'center'},
                        // {field: 'stuage', title: '年龄', align:'center',minWidth:150},
                        // {fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
                        {field: 'id', title: 'ID', minWidth: 100, align: "center"},
                        {field: 'name', title: '名称', align: 'center'},
                        {field: 'area', title: '地区', align: 'center', minWidth: 150},
                        {field: 'real_name', title: '客户经理', minWidth: 100, align: "center",width:238},
                        {field: 'Diname', title: '客户等级', align: 'center',width:200},
                        {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 250}
                    ]]
                });
            });
        })
    })
</script>

</body>
</html>
